package br.ufpe.cin.msc.jrsj2.recommender.message;

import java.util.List;

import org.xml.sax.Attributes;

public class OntologyDuplicatedInstanceMessage extends ApplicationMessage {

	private boolean selectedInstanceElement;
	private String selectedInstance;

	public OntologyDuplicatedInstanceMessage() {
		selectedInstanceElement = false;
		selectedInstance = "";
	}

	@Override
	protected void parseMessageElement(String uri, String localName,
			String qName, Attributes attributes) {
		if (selectedInstance.isEmpty() && qName.equals("pid"))
			selectedInstanceElement = true;
	}

	@SuppressWarnings("rawtypes")
	@Override
	protected void buildResponseMessage(List objects) {
	}

	@Override
	protected void parseMessageContent(char[] ch, int start, int length) {
		if (selectedInstanceElement)
			selectedInstance = String.copyValueOf(ch, start, length);
	}

	@Override
	protected void parseMessageEndElement(String uri, String localName,
			String qName) {
		if (selectedInstanceElement)
			selectedInstanceElement = false;
	}

	public String getSelectedInstance() {
		return this.selectedInstance;
	}

}
